package abi

import (
	"github.com/beego/beego/v2/core/logs"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/ethclient"
)

var LotteryObj *Lottery
var client *ethclient.Client
var err error
var contractAddress = "0x71d2DEDE2f7927AB7533B46FbD923B5E64D13C1A"
var Log *logs.BeeLogger

func init() {
	client, err = ethclient.Dial("http://127.0.0.1:8545")
	if err != nil {
		panic("连接以太坊失败合约失败")
	}
	// 定义要操作的合约账户地址
	addr := common.HexToAddress(contractAddress)
	LotteryObj, err = NewLottery(addr, client)
	if err != nil {
		panic("实例化合约失败")
	}
	Log = logs.NewLogger(1000)
	err := Log.SetLogger("console", "")
	if err != nil {
		panic("设置日志失败")
	}
	Log.SetLevel(logs.LevelDebug)
	Log.EnableFuncCallDepth(true)
}
